{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using DifferentialEquations\n",
    "using PyPlot\n",
    "using ReactionMechanismSimulator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "phaseDict = readinput(\"../src/testing/superminimal.rms\") #load mechanism dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "spcs = phaseDict[\"phase\"][\"Species\"]; #mechanism dictionaries index:  phaseDict[phasename][\"Species\" or \"Reactions\"]\n",
    "rxns = phaseDict[\"phase\"][\"Reactions\"];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ig = IdealGas(spcs,rxns,name=\"gas\"); #Define the phase (how species thermodynamic and kinetic properties calculated)\n",
    "initialconds = Dict([\"T\"=>1000.0,\"P\"=>1e5,\"H2\"=>0.67,\"O2\"=>0.33]); #Set simulation Initial Temp and Pressure\n",
    "domain,y0 = ConstantTPDomain(phase=ig,initialconds=initialconds;sensitivity=true); #Define the domain (encodes how system thermodynamic properties calculated)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "react = Reactor(domain,y0,(0.0,150.1)); #Create the reactor object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "sol = solve(react.ode,DifferentialEquations.CVODE_BDF(),abstol=1e-20,reltol=1e-12); #solve the ode associated with the reactor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bsol = Simulation(sol,domain);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotmolefractions(bsol,150.0; t0=1e-15, N=1000, tol=0.01, exclude=[\"O2\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotmaxratesensitivity(bsol,\"H2\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotmaxthermosensitivity(bsol,\"H2\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotrops(bsol,\"OH\",tol=0.01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Julia 1.1.0",
   "language": "julia",
   "name": "julia-1.1"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.1.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
